package com.media.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.content.base.model.PageParams;
import com.content.base.model.PageResult;
import com.media.dto.QueryMediaParamsDto;
import com.media.dto.UploadFileDto;
import com.media.response.RestResponse;
import com.media.po.MediaFiles;
import com.media.vo.MediaFileVo;
import io.minio.errors.*;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

/**
 * <p>
 * 媒资信息 服务类
 * </p>
 *
 * @author ling
 * @since 2024-12-20
 */
@Service
public interface MediaFilesService extends IService<MediaFiles> {

    MediaFileVo uploadFiles(UploadFileDto dto, Long companyId, String absolutePath,String objectName) throws IOException, ServerException, InsufficientDataException, ErrorResponseException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException;

    MediaFiles addMediaFiles(Long companyId, String bucketName, String absolutePath,UploadFileDto dto,String objectName)throws IOException;

    RestResponse<Boolean> checkFile(String fileMd5);

    RestResponse<Boolean> checkChunk(String fileMd5, int chunk);

    RestResponse<Boolean> uploadChunk(String absolutePath, String fileMd5, int chunk);

    RestResponse<Boolean> mergechunks(String fileMd5, String fileName, int chunkTotal);
    void addBigMediaFiles(Long companyId,String bucketName2,String mergeFilePath,UploadFileDto uploadFileDto,String fileMd5);
    public File downLoadFile(String bucket, String objectName) throws IOException;
    public boolean addMediaFilesToMinIO(String localFilePath,String mimeType,String bucket, String objectName);

    PageResult<MediaFileVo> getAllMediaFiles(PageParams pageParams, QueryMediaParamsDto queryMediaParamsDto);
}
